package com.lemon.springboot.service.impl;

import com.lemon.springboot.dao.IAccountDao;
import com.lemon.springboot.entity.AccountVo;
import com.lemon.springboot.service.ILoginRegisterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liuli
 * @Date 2020/12/6 4:10
 */
@Service
public class LoginRegisterServiceImpl implements ILoginRegisterService {
    static Logger logger = LoggerFactory.getLogger(LoginRegisterServiceImpl.class);

    @Autowired
    IAccountDao accountDao;

    @Override
    public AccountVo login(String account, String password) {
        return accountDao.findAccByPwdAcc(account, password);
    }

    @Override
    public boolean register(AccountVo account) {
        int count = accountDao.insertAccount(account);
        if (count == 1) {
            return true;
        } else {
            logger.error("insertAccount error. result:{}", count);
            return false;
        }
    }


}
